package org.jackysoft.service;

import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import org.jackysoft.entity.ArmDailyProductReporter;
import org.jackysoft.entity.CollationDailyReport;
import org.jackysoft.entity.Department;
import org.jackysoft.util.RowWatcher;
import org.joda.time.DateTime;
import org.springframework.dao.DataAccessException;

import com.itextpdf.text.DocumentException;

public interface ArmDailyReporterService extends ReporterService<ArmDailyProductReporter> {

	
	

	Collection<ArmDailyProductReporter> gets(DateTime from,DateTime to,Department dept)throws DataAccessException;
		
	
	ArmDailyProductReporter get(int year,int month,int date,Department department) throws DataAccessException;
	
	
	void updateForwardStore(int year,int month);
	
	
	
	/**
	 * @param createDate 截至日期
	 * @return 截至日期生产完成数
	 * */
	Map<String,Double> fetchCurrentComplated(DateTime createDate)throws DataAccessException;
	
	
	/**
	 * 综合每日报表
	 * */
	byte[] collateDaily(DateTime createDate) throws DataAccessException;
	/**获取截至本年本月部门的最后一张日报
	/**
	 * 综合每日报表
	 * */
	byte[] collateDaily(int year,int month,int date) throws DataAccessException;
	
	Collection<ArmDailyProductReporter> getDailyCollation(int year,int month,int date) throws DataAccessException;
	
	void updateCollate (DateTime createDate)throws DataAccessException;
	
	/**
	 * 发布报表
	 * @return true success via false
	 * @throws ExecutionException 
	 * @throws InterruptedException 
	 * @throws DocumentException 
	 * @throws IOException 
	 * @throws BiffException 
	 * */
	boolean publish(int year,int month,int day) throws DataAccessException, InterruptedException, ExecutionException,  IOException, DocumentException;
	
	boolean publish(DateTime cal) throws DataAccessException, InterruptedException, ExecutionException, IOException, DocumentException;
	
	byte[]  getResearchBytes(String id,boolean newable) throws DataAccessException;;

	void updateResearch(String id) throws DataAccessException;
	
	/**
	 * 处理Excel行
	 * @param check 是否检查存在产品
	 * @param content 数据项内容
	 * @param dept 部门
	 * @param rower 行处理器
	 * */
	void checkArmitems(byte[] content, Department dept,RowWatcher rower);

	/**
	 * 返回报表空数据模版
	 * */
	byte[] loadEmptyTemplate(String template);

	/**
	 * 为报表设置公式和清空数据
	 * */
	byte[] reInitiResearch(byte[] data);

	/**
	 * 
	 * 计算报表公式结果
	 * **/
	byte[] evaluateFormulas(byte[] data);

	CollationDailyReport getCollationDailyReport(int year, int month, int date);

	byte[] collateDaily(Collection<ArmDailyProductReporter> rpts);

	byte[] getNewDraft(ArmDailyProductReporter me);	
	
	/**
	 * 取得某年月内所有日报
	 * @return Collection&lt;ArmDailyProductReporter&gt;()
	 * 
	 **/
	Collection<ArmDailyProductReporter> getsOfMonth(int year ,int month);
	
	
	/**
	 * 取得某年月内所有日报
	 * @return Collection&lt;ArmDailyProductReporter&gt;()
	 * 
	 **/
	Collection<ArmDailyProductReporter> getsOfMonth(int year ,int month,Department dept);
	

	ArmDailyProductReporter getByTopDate(DateTime tdate,Department department) throws DataAccessException;

	
	
}


